package com.sqfw.project.wp.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sqfw.framework.aspectj.lang.annotation.Log;
import com.sqfw.framework.aspectj.lang.enums.BusinessType;
import com.sqfw.project.wp.domain.WpUpdateLog;
import com.sqfw.project.wp.service.IWpUpdateLogService;
import com.sqfw.framework.web.controller.BaseController;
import com.sqfw.framework.web.domain.AjaxResult;
import com.sqfw.common.utils.poi.ExcelUtil;
import com.sqfw.framework.web.page.TableDataInfo;

/**
 * 工单修改日志Controller
 * 
 * @author lx
 * @date 2023-06-28
 */
@RestController
@RequestMapping("/wp/wpUpateLog")
public class WpUpdateLogController extends BaseController
{
    @Autowired
    private IWpUpdateLogService wpUpdateLogService;

    /**
     * 查询工单修改日志列表
     */
    @PreAuthorize("@ss.hasPermi('wp:wpUpateLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(WpUpdateLog wpUpdateLog)
    {
        startPage();
        List<WpUpdateLog> list = wpUpdateLogService.selectWpUpdateLogList(wpUpdateLog);
        return getDataTable(list);
    }

    /**
     * 导出工单修改日志列表
     */
    @PreAuthorize("@ss.hasPermi('wp:wpUpateLog:export')")
    @Log(title = "工单修改日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WpUpdateLog wpUpdateLog)
    {
        List<WpUpdateLog> list = wpUpdateLogService.selectWpUpdateLogList(wpUpdateLog);
        ExcelUtil<WpUpdateLog> util = new ExcelUtil<WpUpdateLog>(WpUpdateLog.class);
        util.exportExcel(response, list, "工单修改日志数据");
    }

    /**
     * 获取工单修改日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('wp:wpUpateLog:query')")
    @GetMapping(value = "/{autoId}")
    public AjaxResult getInfo(@PathVariable("autoId") String autoId)
    {
        return success(wpUpdateLogService.selectWpUpdateLogByAutoId(autoId));
    }

    /**
     * 新增工单修改日志
     */
    @PreAuthorize("@ss.hasPermi('wp:wpUpateLog:add')")
    @Log(title = "工单修改日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WpUpdateLog wpUpdateLog)
    {
        return toAjax(wpUpdateLogService.insertWpUpdateLog(wpUpdateLog));
    }

    /**
     * 修改工单修改日志
     */
    @PreAuthorize("@ss.hasPermi('wp:wpUpateLog:edit')")
    @Log(title = "工单修改日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WpUpdateLog wpUpdateLog)
    {
        return toAjax(wpUpdateLogService.updateWpUpdateLog(wpUpdateLog));
    }

    /**
     * 删除工单修改日志
     */
    @PreAuthorize("@ss.hasPermi('wp:wpUpateLog:remove')")
    @Log(title = "工单修改日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{autoIds}")
    public AjaxResult remove(@PathVariable String[] autoIds)
    {
        return toAjax(wpUpdateLogService.deleteWpUpdateLogByAutoIds(autoIds));
    }
}
